package com.yolib.sanyi;

import com.yolib.sanyi.tool.Utility;
import com.yolib.sanyi.tool.YoliBLog;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class NewsContentActivity extends Activity implements OnClickListener{
	
	WebView mWebView;
	String content; 
	ImageView mBack;
	TextView  mTitle;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_news_web);
		
		mWebView = (WebView) findViewById(R.id.activity_news_web_WebView);
		mBack	 = (ImageView)  findViewById(R.id.BackImageView);
		mTitle	 = (TextView)	findViewById(R.id.news_title);
		mBack.setOnClickListener(this);
		
		if(getIntent().getStringExtra("title") != null)
			mTitle.setText(getIntent().getStringExtra("title"));
		
		content = getIntent().getStringExtra("content");
		YoliBLog.e(""+content);
//		"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><BODY><img alt=\"\" src=\"/admin/ckfinder/userfiles/images/14.JPG\" style=\"width: 109px; height: 71px; \" /></BODY></HTML>";
		
//		mWebView.loadDataWithBaseURL(null, content, "text/html; charset=UTF-8", null, null);
//		mWebView.loadData(content, "text/html; charset=UTF-8", null);
//		mWebView.loadData(  
//			    "<html xmlns=\"http://www.w3.org/1999/xhtml\">"  
//			      + "<head>"  
//			      + "<meta http-quiv=\"Content-Type\" content=\"text/html charset=utf-8\" />"  
//			      + "</head>"  
//			      + "<body>"  
//			      + "<img alt=\"\" src=\"/admin/ckfinder/userfiles/images/14.JPG\" style=\"width: 109px; height: 71px; \" />"  
//			      + "</body>"  
//			      + "</html>",  
//			    "text/html; charset=UTF-8",  
//			    "utf-8"); 
		mWebView.loadDataWithBaseURL(  
			    Utility.getAPIURL(),  
			    "<html>"  
			      + "<head>"  
			      + "<meta http-quiv=\"Content-Type\" content=\"text/html charset=utf-8\" />"  
			      + "</head>"  
			      + "<body>"  
			      + content  
			      + "</body>"  
			      + "</html>",  
			    "text/html",  
			    "utf-8",  
			    null);  
	}

	@Override
	public void onClick(View v) {
		switch(v.getId())
		{
		case R.id.BackImageView:
			finish();
			overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);	
			break;
		}
	}
}
